<!-- 项目管理 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label mb10">人才列表</p>
    <!-- sonRouter="yybureauFormationBJ" 为跳转新的页面编辑 -->
    <dxtable
    v-if="jdfsd"
      :dataJson="dataJson"
      :portUrl="portUrl"
      :formJson="formJson"
      :qx="qx"
      ref="databale"
    ></dxtable>
    <div class="vertical-center mt100" v-else>
      <div>
        <div class="spinner">
          <div class="half-circle-spinner">
            <div class="circle circle-1"></div>
            <div class="circle circle-2"></div>
          </div>
        </div>
        <div class="fz12 z9 cen">加载中...</div>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import { dxget, dxpost } from "../../util/index";
import { NButton, NImage, NTag } from "naive-ui";
import { h, ref, reactive } from "vue";
const databale = ref();
const jdfsd = ref()
const initeer = () => {
  databale.value.initDataExpose();
};
let dataJson = [
  {
    title: "头像",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "touxiang",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "姓名",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "name",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
  {
    title: "年龄",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "age",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
  {
    title: "工作经验",
    type: "select",
    val: [],
    options:[],
    span: 12,
    key: "gzjy",
    search: true,
    render: (row) => {
       try{
        return  dataJson[3].options.filter(a=>a.value==row.gzjy)[0].label
       }catch(e){
        
       }
    }
  },
  {
    title: "学历",
    type: "select",
    val: [],
    options:[],
    search: true,
    span: 12,
    key: "xueli",
    render: (row) => {
       try{
        return  dataJson[4].options.filter(a=>a.value==row.xueli)[0].label
       }catch(e){
        
       }
    }
  },
  {
    title: "擅长",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "shanchang",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "排序",
    width: 100,
    render: (row) => {
      row.sjk = "chuanbo"; //数据库
      row.databaseName = "rencai"; //表名
      return h(sort, {
        row,
        onCallBack: () => {
          initeer();
        },
      });
    },
  },
  {
    title: "添加时间",
    key: "addTime",
    width: 150,
  },
];

const qx = {
  DeletePermissionID: "cbrcrencaidel", //删除
  EditPermissionIdentifier: "cbrcrencaibj", // 编辑
  NewPermissionIdentifier: "cbrcrencaixz", // 新建
  ViewPermissionID: "cbrcrencaick", // 查看
};
const portUrl = "cbrc/rencai/rencai";

let formJson = reactive([
  {
    title: "头像",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "touxiang",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "姓名",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "name",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "年龄",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "age",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "工作经验",
    type: "select",
    val: [],
    options:[],
    span: 12,
    key: "gzjy",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "学历",
    type: "select",
    val: [],
    options:[],
    span: 12,
    key: "xueli",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "擅长",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "shanchang",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "简介",
    type: "textarea",
    val: "",
    icon: "dx-duohangwenben",
    span: 24,
    key: "jianjie",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
]);
const czFun = {
  fun: (row) => {
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {},
        },
        "复制代码"
      ),
    ];
  },
};

// 获取字典内容
const xtgxxmfl = async () => {
  const sdfds1 = await dxget("dxgjAdmin/getzd", { name: 'cbrcjinyan' })
  const sdfds2 = await dxget("dxgjAdmin/getzd", { name: 'cbrcxueli' })
  dataJson[3].options = [
    {
      label: "全部",
      value: ""
    },
    ...sdfds1.data
  ]
  formJson[3].options = sdfds1.data
  dataJson[4].options = [
    {
      label: "全部",
      value: ""
    },
    ...sdfds2.data
  ]
  formJson[4].options = sdfds2.data
  jdfsd.value = true
}
xtgxxmfl()
</script>
<style scoped></style>
